package com.example.forum.dao;

import com.example.forum.model.Board;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface BoardMapper {
    int insert(Board row);

    int insertSelective(Board row);

    Board selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Board row);

    int updateByPrimaryKey(Board row);

    List<Board> selectTopNBoard(@Param("num") Integer num);

    /**
     * 将对应板块的帖子数减一,若板块的文章数为 0 或者板块信息已被删除则不执行
     *
     * @param id 板块id
     * @return 受影响的行数
     */
    int delOneArticleCountById(@Param("id") Long id);
}